package test.designpattern.strategy;

/**
 * @author YuFeng
 * @create 2018-12-20 19:19
 * @desc 收费对象容器
 **/
public class CashContent {
    private CashStrategy cashStrategy;

    public CashContent(CashStragtegyType type, double money) {
        switch (type) {
            case DISCOUNT://打8折
                this.cashStrategy = new DiscountStrategy(money, 0.8);
                break;
            case REBATE:
                this.cashStrategy = new RebateStrategy(money, 300, 100);
                break;
            default:
                this.cashStrategy = new NormalStrategy(money);

        }
    }

    public double getResult() {
        return this.cashStrategy.calculate();
    }
}
